package com.jozen.smart_toilet_system.ui;

import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jozen.modelbase.netwoek.bean.HomeModel;
import com.jozen.modelbase.netwoek.util.GlideUtil;
import com.jozen.smart_toilet_system.R;

public class DevTypeAdapter extends BaseQuickAdapter<HomeModel.EnvDataListDto, BaseViewHolder> {

    public DevTypeAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeModel.EnvDataListDto item) {
        try {
            helper.setText(R.id.tv_dev_name, item.getModelName() + "");
            ImageView iv_dev_img = helper.getView(R.id.iv_dev_img);
            RelativeLayout rl_img_view=helper.getView(R.id.rl_img_view);
            if (!TextUtils.isEmpty(item.getIconURL())) {
                GlideUtil.loadImageWithoutCache(item.getIconURL(), iv_dev_img);
            } else {
                switch (item.getModelId()) {
                    case 1://剩余洗手液
                        helper.setImageResource(R.id.iv_dev_img, R.drawable.ic_hand_sanitizer);
                        break;
                    case 2://剩余厕纸
                        helper.setImageResource(R.id.iv_dev_img, R.drawable.ic_tissue);
                        break;
                    case 3://温度
                        helper.setImageResource(R.id.iv_dev_img, R.drawable.ic_temp);
                        break;
                    case 4://湿度
                        helper.setImageResource(R.id.iv_dev_img, R.drawable.ic_hum);
                        break;
                    case 5://氨气
                        helper.setImageResource(R.id.iv_dev_img, R.drawable.ic_ammonia_gas);
                        break;
                    case 6://硫化氢
                        helper.setImageResource(R.id.iv_dev_img, R.drawable.ic_hydrogen_sulfide);
                        break;
                    case 7://PM2.5
                        helper.setImageResource(R.id.iv_dev_img, R.drawable.ic_pm);
                        break;
                    case 8://VOC
                        helper.setImageResource(R.id.iv_dev_img, R.drawable.ic_voc);
                        break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
